%============================================================================
% Sensorless Brushless DC Motor Reference Design
%
%  This application note is from SILICON LABS, AN208, Rev. 0.2/06.
%  
%  Translate to Chinese by boolhead(gmail),April,4,2012, 
%  Current Rev. 0.21/06-CN.
% License:
%  1. Chinese version only for reference under non-commercial condition, 
%     you can modify & redistribute it if you keep this file header.
%     any application follows this document are under your own risk, 
%     original AN208 are prefer & strongly recommend.
%  2. all rights of original document are belongs to SILICON LABS.
%============================================================================

\documentclass[a4paper,11pt]{scrreprt}

\usepackage{ctexcap}

\usepackage{tabularx}
\usepackage{multirow}
\usepackage{multicol}

\usepackage{float}
\floatstyle{ruled}

\usepackage{hyperref}
\usepackage{enumitem}

\usepackage{optional}

\usepackage[table]{xcolor}

\newcommand{\companyname}{Silicon Labs}

\hypersetup{% add some values to the pdf properties
  colorlinks = true,
  pdfstartview = FitV,
  linkcolor = blue,
  citecolor = blue,
  urlcolor = blue,
  pdftitle = {AN208},
  pdfauthor = {SiliconLabs},
  pdfsubject = {Sensorless Brushless DC Motor Reference Design}
}

\newcommand{\fname}[1]{\texttt{#1}}
\newcommand{\tabeltc}[1]{{\centering #1 \par}}
\newcommand{\tabelth}[1]{{\centering \textbf{\textit{#1}} \par}}

\newcommand{\fixme}[1]{\textbf{\textcolor{red}{#1}}}

% Colors used to typeset table headers and alternating table rows
\colorlet{tblhdrbgcolor}{blue!30} % Background color for headers
\colorlet{tbloddrowbgcolor}{blue!10} % Background color for odd rows (headers not included)
\colorlet{tblevenrowbgcolor}{white} % Background color for even rows (headers not included)

\usepackage{fancyhdr}
\usepackage{graphicx}
\usepackage{verbatim}
\usepackage{makeidx}
\usepackage{fancyvrb}
\usepackage{color}
\ifpdfoutput{\usepackage{booktabs}}%
  {\newcommand{%
    \toprule}{}\newcommand{\midrule}{\hline}\newcommand{\bottomrule}{}%
  }
\usepackage{longtable}
\usepackage{url}
\urlstyle{sf}
\usepackage{marvosym}
\usepackage{ifthen}
\usepackage{rotating}

% pdf output: try pdf first, then png and jpg as file format
% html output: try png first, then jpg. Ignore pdf files
% this only applies if no file extension is given!
\ifpdfoutput{\DeclareGraphicsExtensions{.pdf,.png,.jpg}}%
    {\DeclareGraphicsExtensions{.png,.jpg}}

% fancy header style adjustments
\fancyhead{}
\fancyfoot{}
\fancyhead[L]{{\nouppercase{\textsc{\leftmark}}}}
\fancyhead[R]{\iffloatpage{}{\thepage}}
\fancyfoot[L]{\textsc{}}
\fancyfoot[R]{\textsc{}}
\fancypagestyle{plain}{}

\renewcommand{\headrulewidth}{\iffloatpage{0pt}{0.4pt}}
\renewcommand{\footrulewidth}{\iffloatpage{0pt}{0.4pt}}
\setlength{\headheight}{18.5pt}
\newcounter{example}[chapter]

\ifpdfoutput{%
  \renewcommand{\toprule}{\specialrule{\heavyrulewidth}{\abovetopsep}{0pt}}
  \renewcommand{\midrule}{\specialrule{\lightrulewidth}{0pt}{\belowrulesep}}
  }{}
\newcommand{\tblhdrstrut}{\rule[-1.3ex]{0mm}{4.0ex}}


%% \newenvironment{example}
%%     {\stepcounter{example}\paragraph{Example \theexample:}}
%%     {\hfill$\Box$

%%     \bigskip
%%     \noindent}

% found on the internet, posting by Donald Arseneau
% I may as well include my robust expandable definions, which can be
% used in \edef or \write where the \def would not be executed:
%
% \if\blank --- checks if parameter is blank (Spaces count as blank)
% \if\given --- checks if parameter is not blank: like \if\blank{#1}\else
% \if\nil --- checks if parameter is null (spaces are NOT null)
% use \if\given{ } ... \else ... \fi etc.
%
{\catcode`\!=8 % funny catcode so ! will be a delimiter
\catcode`\Q=3 % funny catcode so Q will be a delimiter
\long\gdef\given#1{88\fi\Ifbl@nk#1QQQ\empty!}
\long\gdef\blank#1{88\fi\Ifbl@nk#1QQ..!}% if null or spaces
\long\gdef\nil#1{\IfN@Ught#1* {#1}!}% if null
\long\gdef\IfN@Ught#1 #2!{\blank{#2}}
\long\gdef\Ifbl@nk#1#2Q#3!{\ifx#3}% same as above
}

% add screenshot image.
% Usage: \screenshot{filename}{caption}{label}
% By using the 'H' (HERE) placement, the screenshots are placed where
% we want them.
% Note: use this only for screenshots!
% Note: leave caption empty to supress it.
\newcommand{\screenshot}[4]{
  \begin{figure}[H]
    \begin{center}
      \IfFileExists{#1.jpg}
        {\includegraphics[width=#4pt]{#1.jpg}
         \typeout{Note: device specific image used}}
        {\typeout{Missing image: #1}%
         \color{red}{\textbf{WARNING!} Image not found}%
        }
      \if\blank{#3}\else{\label{#3}}\fi\if\blank{#2}\else{%
        \caption{#2}}\fi
    \end{center}
  \end{figure}
}

% generate index
\usepackage{makeidx}
\makeindex
